//
//  ZM_LSwich_TVCell.m
//  YYFMMall
//
//  Created by chenzm on 2019/9/27.
//  Copyright © 2019 YuYou1. All rights reserved.
//

#import "ZM_LSwich_TVCell.h"

@interface ZM_LSwich_TVCell()

@end

@implementation ZM_LSwich_TVCell

#pragma mark - 赋值


#pragma mark - Methods
-(void)valueChanged:(UISwitch *)sender{
    !self.swichChangeBlock?:self.swichChangeBlock(sender,sender.isOn);
}


#pragma mark - Intial
-(instancetype)initWithStyle:(UITableViewCellStyle)style reuseIdentifier:(NSString *)reuseIdentifier{
    if (self = [super initWithStyle:style reuseIdentifier:reuseIdentifier]) {
        [self setUpBaseData];
        [self setUpUI];
    }
    return self;
}

///基本数据设置
-(void)setUpBaseData{
    
}
///添加控件
-(void)setUpUI{
    [self lbl];
    [self swich];
    [self lineV];
}


#pragma mark - 布局


#pragma mark - lazyLoad
-(UILabel *)lbl{
    if (!_lbl) {
        _lbl = [UILabel new];
        _lbl.tintColor = kLineColor;
        _lbl.font = kMediumFont(14);
        _lbl.textAlignment = NSTextAlignmentLeft;
        [self addSubview:_lbl];
        [_lbl mas_makeConstraints:^(MASConstraintMaker *make) {
            make.bottom.top.mas_equalTo(self);
            make.left.mas_equalTo(15);
            make.right.mas_equalTo(self.swich.mas_left).offset(10);
        }];
    }
    return _lbl;
}

-(UIView *)lineV{
    if (!_lineV) {
        _lineV = [UIView new];
        _lineV.hidden = YES;
        _lineV.backgroundColor = kHexColor(0xEEEEEE);
        [self addSubview:_lineV];
        [_lineV mas_makeConstraints:^(MASConstraintMaker *make) {
            make.bottom.mas_equalTo(self);
            make.left.mas_equalTo(15);
            make.right.mas_equalTo(-15);
            make.height.mas_equalTo(1);
        }];
    }
    return _lineV;
}


-(UISwitch *)swich{
    if (!_swich) {
        _swich = [[UISwitch alloc]init];
        _swich.on = NO;
        _swich.tintColor = kHexColor(0xD2D2D2);
        _swich.backgroundColor = _swich.tintColor;
        _swich.onTintColor = kMainColor;
        [_swich addTarget:self action:@selector(valueChanged:) forControlEvents:(UIControlEventValueChanged)];
        [self addSubview:_swich];
        [_swich mas_makeConstraints:^(MASConstraintMaker *make) {
            make.centerY.mas_equalTo(self);
            make.right.mas_equalTo(-15);
        }];
        [ZMSpeedy zm_changeControl:_swich cornerRadius:_swich.mj_h/2 borderWidth:0 borderColor:nil mask:YES];
    }
    return _swich;
}

@end


